import QtQuick
import Qt5Compat.GraphicalEffects

Item {
    id: roundImage
    property alias sourceSize: image.sourceSize
    property int size: 40
    property int heightSize: 0
    property string source
    property double radius: 20
    property alias fillMode: image.fillMode
    width: size
    height: heightSize === 0 ? size : heightSize
    //加载成功回调
    signal loaded
    Image {
        id: image
        anchors.fill: parent
        source: parent.source
        fillMode: Image.PreserveAspectCrop
        smooth: true
        visible: false
        antialiasing: true
        onProgressChanged: function (e) {
            if (progress === 1) {
                loaded();
            }
        }
        onSourceChanged: {
            if (progress === 1) {
                loaded();
            }
        }
    }

    OpacityMask {
        anchors.fill: parent
        source: image
        maskSource: mask
        // antialiasing: true
        smooth: true
    }

    Rectangle {
        id: mask
        anchors.fill: parent
        visible: false
        radius: parent.radius
    }
}
